﻿#include <iostream>
class object {
public:
    int x;
    int y;
    object() {
        std::cout << "object was created" << std::endl;
    }
    object(const object& obj) {
        std::cout << "object was created by copy" << std::endl;
    }
    ~object() {
        std::cout << "object was -" << std::endl;
    }
    void Show() {
        std::cout << x << std::endl;
    }
};
class mapObject :public object {
public:
    int x;
    int mapId;
    mapObject() {
        x = 2500;
        object::x = 3500;//父类的x，需要函数访问
        std::cout << "mapObject was created" << std::endl;
    }
    mapObject(const mapObject& obj) {
        std::cout << "mapObject was created by copy" << std::endl;
    }
    mapObject(int id) :mapId{ id } {
        std::cout << id << std::endl;
    }
    ~mapObject() {
        std::cout << "mapObject was -" << std::endl;
    }
    void Show(int p) {
        std::cout << x << std::endl;
    }
    using object::Show;
};
class actObject :public mapObject {
public:
    using mapObject::mapObject;
    int damage;
    actObject() :mapObject{ 100 } {//规定运行mapObject(int id) :mapId{ id }函数，mapId要放在函数内使用
   // actObject() : mapId{ 100 } {//父类的mapId要放在函数内使用
        std::cout<<"actObject was created" << std::endl;
    }
    actObject(const actObject& obj) :mapObject{ obj } {
        std::cout<<"actObject was created by copy" << std::endl;
    }
    actObject(int id) :damage{ id } {
        std::cout << id+1 << std::endl;
    }
    ~actObject() {
        std::cout << "actObject was -" << std::endl;
    }
};
int main()
{
    //actObject obj{10};//先构造object，再构造mapObject，最后构造actObject
    //actObject obj1 = obj;//先构造object，再构造mapObject，最后运行actObject副本构造函数
    mapObject MAP;

    MAP.x = 250;
    MAP.object::x=20;

    MAP.Show(150);
    MAP.object::Show(2500);
}